package com.example.movie.mate.controller;

import com.example.movie.mate.pojo.param.PlayScheduleAddNewParam;
import com.example.movie.mate.pojo.vo.PlayScheduleVO;
import com.example.movie.mate.service.IPlayScheduleService;
import com.example.movie.mate.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.List;

/**
 * 放映计划控制器
 */
@Tag(name = "5. 放映计划管理模块")
@RestController
@RequestMapping("/api/play-schedule")
public class PlayScheduleController {
    /**
     * 放映计划服务
     */
    @Autowired
    private IPlayScheduleService playScheduleService;

    @Operation(summary = "[管理] 新增放映计划")
    @ApiOperationSupport(order = 100)
    @PostMapping("/manage/add-new")
    public JsonResult<Void> addNew(@ParameterObject PlayScheduleAddNewParam param) {
        playScheduleService.addNew(param);
        return JsonResult.ok();
    }

    @Operation(summary = "[游客] 查询某电影某天的放映计划列表")
    @ApiOperationSupport(order = 420)
    @Parameter(name = "movieId", description = "电影id", required = true, example = "1")
    @Parameter(name = "date", description = "日期", required = true, example = "2025-01-01")
    @GetMapping("/public/select-by-movie-and-date")
    public JsonResult<List<PlayScheduleVO>> selectByMovieIdAndDate(Long movieId, LocalDate date) {
        List<PlayScheduleVO> list = playScheduleService.selectByMovieIdAndDate(movieId, date);
        return JsonResult.ok(list);
    }

    @Operation(summary = "[游客] 查询某影厅某天的放映计划列表")
    @ApiOperationSupport(order = 421)
    @Parameter(name = "hallId", description = "影厅id", required = true, example = "1")
    @Parameter(name = "date", description = "日期", required = true, example = "2025-01-01")
    @GetMapping("/public/select-by-hall-and-date")
    public JsonResult<List<PlayScheduleVO>> selectByHallIdAndDate(Long hallId, LocalDate date) {
        List<PlayScheduleVO> list = playScheduleService.selectByHallIdAndDate(hallId, date);
        return JsonResult.ok(list);
    }

}